package com.xuecheng.content.api;

import com.xuecheng.content.model.dto.AddCourseDto;
import com.xuecheng.content.model.dto.CourseBaseInfoDto;
import com.xuecheng.content.model.dto.CourseCategoryTreeDto;
import com.xuecheng.content.model.dto.EditCourseDto;
import com.xuecheng.content.service.CourseCategoryService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 数据字典 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
public class CourseCategoryController {

    @Autowired
    private CourseCategoryService courseCategoryService;

    @GetMapping("/course-category/tree-nodes")
    @ApiOperation("列表查询")
    public List<CourseCategoryTreeDto> queryTreeNodes() {
        //
       return  courseCategoryService.queryTreeNodes("1");
    }

    @PostMapping("/course")
    @ApiOperation("新增课程")
    public CourseBaseInfoDto createCourseBase(@RequestBody AddCourseDto addCourseDto){

        Long companyId = 1232141425L;
       return  courseCategoryService.createCourseBase(companyId,addCourseDto);
    }

    @GetMapping("/course/{id}")
    @ApiOperation("根据id查询课程信息")
    public  CourseBaseInfoDto getCourseById(@PathVariable Long id){
        return courseCategoryService.getCourseById(id);
    }

    @PutMapping("/course")
    @ApiOperation("修改课程信息")
    public CourseBaseInfoDto modifyCourse(@RequestBody EditCourseDto editCourseDto){
        Long companyId = 1232141425L;
        return courseCategoryService.modifyCourse(companyId,editCourseDto);
    }
}